from conf import settings
import sys
import os

dic = {"name": None, "flag": None}


class Network:
    lst = [("注册", "register"), ("登录", "login"), ("上传", "upload"), ("下载", "download")]

    # 注册
    def register(self, name_pwd):
        """
        注册
        :return:
        """
        with open(settings.BASE_INFO, "a", encoding="utf-8")as f:
            f.write(f"{name_pwd}\n")
        return "注册成功！"

    # 登录
    def login(self, name_pwd):
        """
        登录
        :return:
        """
        with open(settings.BASE_INFO, "r", encoding="utf-8")as f:
            for i in f:
                if name_pwd == i.strip():
                    return "登录成功！"
            else:
                return "密码错误请重新登录"
